package com.iplant.mes.service.po.sfc;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.mes.service.mesenum.sfc.SFCTaskReportMode;
import com.iplant.mes.service.mesenum.sfc.SFCTaskReportStatus;
import com.iplant.pdm.service.basicenum.pdm.PDMComponentTypes;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * 报工单
 *
 * @author YouWang·Peng
 * 2023-8-30 10:51:37
 */
@DBBasePO(TableName = "sfc_task_report", Name = false, Active = false, Schemas = DBSchemas.MES,
        CheckName = {"Code"}, CodeAuto = true, CodePrefix = "STR" +
        "-{yyMMdd}-",
        CodeNum = 4)
public class SFCTaskReport extends BasePO {
    @DBCondition
    @DBField
    public int OrderID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBField
    public String OrderNo = "";

    @DBCondition
    @DBField
    public int RoutePartID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fpc_routepart", tableAsName = "fpc_routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public String RoutePartName = "";

    @DBCondition
    @DBField
    public int RoutePartPointID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1", Schemas =
            DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public String RoutePartPointName = "";

    @DBCondition
    @DBJoin(name = "ComponentType", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1", Schemas =
            DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public int ComponentType = 0;

    /**
     * 产出类型
     */
    public String ComponentTypeText = "";

    @DBCondition
    @DBField
    public int ProductID = 0;

    @DBJoin(name = "Code", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public String ProductCode = "";

    @DBJoin(name = "ComponentNumber", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public int ComponentNumber = 1;

    @DBField
    public int TaskPartID;
    @DBField
    public int TaskPartPointID;

    @DBCondition
    @DBField
    public int TaskPartPointDayID;

    @DBCondition
    @DBField
    public int TaskSelfID;

    /**
     * 车间ID
     */
    @DBCondition
    @DBField
    public int WorkShopID = 0;
    @DBJoin(name = "Name", tableName = "fmc_workshop", tableAsName = "workshop1", Schemas = DBSchemas.Basic,
            JoinIndex = 2,
            MainTableField = "WorkShopID")
    public String WorkShopName = "";
    /**
     * 车间编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workshop", tableAsName = "workshop1", Schemas = DBSchemas.Basic,
            JoinIndex = 2,
            MainTableField = "WorkShopID")
    public String WorkShopCode = "";

    /**
     * 工区ID
     */
    @DBCondition
    @DBField
    public int WorkAreaID = 0;
    /**
     * 工区名称
     */
    @DBJoin(name = "Name", tableName = "fmc_workarea", tableAsName = "workarea1", Schemas = DBSchemas.Basic,
            JoinIndex = 3,
            MainTableField = "WorkAreaID")
    public String WorkAreaName = "";
    /**
     * 工区编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workarea", tableAsName = "workarea1", Schemas = DBSchemas.Basic,
            JoinIndex = 3,
            MainTableField = "WorkAreaID")
    public String WorkAreaCode = "";

    /**
     * 工位ID
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.in)
    @DBField
    public int StationID = 0;
    /**
     * 工位名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fmc_station", tableAsName = "station1", Schemas = DBSchemas.Basic,
            JoinIndex = 4,
            MainTableField = "StationID")
    public String StationName = "";
    /**
     * 工位编码
     */
    @DBJoin(name = "Code", tableName = "fmc_station", tableAsName = "station1", Schemas = DBSchemas.Basic,
            JoinIndex = 4,
            MainTableField = "StationID")
    public String StationCode = "";

    /**
     * 计划日期
     */
    @DBCondition
    @DBJoin(name = "StationDate", tableName = "sfc_task_self", tableAsName = "sfc_task_self1", Schemas = DBSchemas.MES,
            MainTableField = "TaskSelfID")
    public Calendar StationDate = Calendar.getInstance();

    /**
     * 班次
     */
    @DBCondition
    @DBJoin(name = "ShiftType", tableName = "sfc_task_self", tableAsName = "sfc_task_self1", Schemas = DBSchemas.MES,
            MainTableField = "TaskSelfID")
    public int ShiftType = 0;

    /**
     * 原计划数量
     */
    @DBJoin(name = "PlantNum", tableName = "aps_task_partpoint_day", tableAsName = "aps_task_partpoint_day1", Schemas =
            DBSchemas.APS,
            JoinIndex = 4,
            MainTableField = "TaskPartPointDayID")
    public float SPlantNum = 0.0f;

    /**
     * 当班次班组长确定计划数
     */
    @DBJoin(name = "DPlantNum", tableName = "aps_task_partpoint_day", tableAsName = "aps_task_partpoint_day1", Schemas =
            DBSchemas.APS,
            JoinIndex = 4,
            MainTableField = "TaskPartPointDayID")
    public float DPlantNum = 0.0f;
    /**
     * 工序任务在某个工位的计划数
     */
    @DBJoin(name = "PlantNum", tableName = "sfc_task_self", tableAsName = "sfc_task_self1", Schemas = DBSchemas.MES,
            JoinIndex = 2,
            MainTableField = "TaskSelfID")
    public float PlantNum = 0.0f;

    /**
     * 实际执行数量
     */
    @DBField
    public float ActNum = 0.0f;

    @DBCondition(CompareType = DBCondition.DBCompareType.in)
    @DBField
    public int Status = 0;

    public String StatusText = "";

    /**
     * 报工模式
     */
    @DBCondition
    @DBField
    public int ReportMode = 0;

    /**
     * 报工模式文本
     */
    public String ReportModeText = "";

    /**
     * 待确认的交接人列表
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.findInSet)
    @DBField
    public List<Integer> HandoverList = new ArrayList<>();

    @DBJoinMulti(Name = "Name", MainTableField = "HandoverList", TableName = "mbs_user", Schemas = DBSchemas.Basic)
    public String HandoverNames = "";

    /**
     * 确认人ID
     */
    @DBCondition
    @DBField
    public int ConfirmID = 0;
    /**
     * 确认人名称
     */
    @DBJoin(name = "Name", tableName = "mbs_user", tableAsName = "mbs_user1", Schemas = DBSchemas.Basic,
            MainTableField = "ConfirmID")
    public String ConfirmName = "";

    /**
     * 确认时刻
     */
    @DBField
    public Calendar ConfirmTime = Calendar.getInstance();

    /**
     * 报废数量
     */
    @DBField
    public float BadNum = 0.0f;

    /**
     * 是否为返修报工单
     */
    @DBCondition
    @DBField
    public int IsRepairPlan = 0;

    /**
     * 返修单ID
     */
    @DBCondition
    @DBField
    public int ProductRepairID = 0;

    public SFCTaskReport() {
    }

    public SFCTaskReport(int orderID, int routePartID, int routePartPointID, int productID, int taskPartID,
                         int taskPartPointID, int taskPartPointDayID, int taskSelfID, int workShopID, int workAreaID,
                         int stationID, Calendar stationDate, int shiftType, float actNum, int status, int reportMode
            , float badNum) {
        OrderID = orderID;
        RoutePartID = routePartID;
        RoutePartPointID = routePartPointID;
        ProductID = productID;
        TaskPartID = taskPartID;
        TaskPartPointID = taskPartPointID;
        TaskPartPointDayID = taskPartPointDayID;
        TaskSelfID = taskSelfID;
        WorkShopID = workShopID;
        WorkAreaID = workAreaID;
        StationID = stationID;
        StationDate = stationDate;
        ShiftType = shiftType;
        ActNum = actNum;
        Status = status;
        ReportMode = reportMode;
        BadNum = badNum;
    }

    @JsonProperty("OrderID")
    public int getOrderID() {
        return OrderID;
    }

    public void setOrderID(int orderID) {
        OrderID = orderID;
    }

    @JsonProperty("OrderNo")
    public String getOrderNo() {
        return OrderNo;
    }

    public void setOrderNo(String orderNo) {
        OrderNo = orderNo;
    }

    @JsonProperty("RoutePartID")
    public int getRoutePartID() {
        return RoutePartID;
    }

    public void setRoutePartID(int routePartID) {
        RoutePartID = routePartID;
    }

    @JsonProperty("RoutePartName")
    public String getRoutePartName() {
        return RoutePartName;
    }

    public void setRoutePartName(String routePartName) {
        RoutePartName = routePartName;
    }

    @JsonProperty("RoutePartPointID")
    public int getRoutePartPointID() {
        return RoutePartPointID;
    }

    public void setRoutePartPointID(int routePartPointID) {
        RoutePartPointID = routePartPointID;
    }

    @JsonProperty("RoutePartPointName")
    public String getRoutePartPointName() {
        return RoutePartPointName;
    }

    public void setRoutePartPointName(String routePartPointName) {
        RoutePartPointName = routePartPointName;
    }

    @JsonProperty("ComponentType")
    public int getComponentType() {
        return ComponentType;
    }

    public void setComponentType(int componentType) {
        ComponentType = componentType;
    }

    @JsonProperty("ProductID")
    public int getProductID() {
        return ProductID;
    }

    public void setProductID(int productID) {
        ProductID = productID;
    }

    @JsonProperty("ProductCode")
    public String getProductCode() {
        return ProductCode;
    }

    public void setProductCode(String productCode) {
        ProductCode = productCode;
    }

    @JsonProperty("ComponentNumber")
    public int getComponentNumber() {
        return ComponentNumber;
    }

    public void setComponentNumber(int componentNumber) {
        ComponentNumber = componentNumber;
    }

    @JsonProperty("TaskPartID")
    public int getTaskPartID() {
        return TaskPartID;
    }

    public void setTaskPartID(int taskPartID) {
        TaskPartID = taskPartID;
    }

    @JsonProperty("TaskPartPointID")
    public int getTaskPartPointID() {
        return TaskPartPointID;
    }

    public void setTaskPartPointID(int taskPartPointID) {
        TaskPartPointID = taskPartPointID;
    }

    @JsonProperty("TaskPartPointDayID")
    public int getTaskPartPointDayID() {
        return TaskPartPointDayID;
    }

    public void setTaskPartPointDayID(int taskPartPointDayID) {
        TaskPartPointDayID = taskPartPointDayID;
    }

    @JsonProperty("TaskSelfID")
    public int getTaskSelfID() {
        return TaskSelfID;
    }

    public void setTaskSelfID(int taskSelfID) {
        TaskSelfID = taskSelfID;
    }

    @JsonProperty("WorkShopID")
    public int getWorkShopID() {
        return WorkShopID;
    }

    public void setWorkShopID(int workShopID) {
        WorkShopID = workShopID;
    }

    @JsonProperty("WorkShopName")
    public String getWorkShopName() {
        return WorkShopName;
    }

    public void setWorkShopName(String workShopName) {
        WorkShopName = workShopName;
    }

    @JsonProperty("WorkShopCode")
    public String getWorkShopCode() {
        return WorkShopCode;
    }

    public void setWorkShopCode(String workShopCode) {
        WorkShopCode = workShopCode;
    }

    @JsonProperty("WorkAreaID")
    public int getWorkAreaID() {
        return WorkAreaID;
    }

    public void setWorkAreaID(int workAreaID) {
        WorkAreaID = workAreaID;
    }

    @JsonProperty("WorkAreaName")
    public String getWorkAreaName() {
        return WorkAreaName;
    }

    public void setWorkAreaName(String workAreaName) {
        WorkAreaName = workAreaName;
    }

    @JsonProperty("WorkAreaCode")
    public String getWorkAreaCode() {
        return WorkAreaCode;
    }

    public void setWorkAreaCode(String workAreaCode) {
        WorkAreaCode = workAreaCode;
    }

    @JsonProperty("StationID")
    public int getStationID() {
        return StationID;
    }

    public void setStationID(int stationID) {
        StationID = stationID;
    }

    @JsonProperty("StationName")
    public String getStationName() {
        return StationName;
    }

    public void setStationName(String stationName) {
        StationName = stationName;
    }

    @JsonProperty("StationCode")
    public String getStationCode() {
        return StationCode;
    }

    public void setStationCode(String stationCode) {
        StationCode = stationCode;
    }

    @JsonProperty("StationDate")
    public Calendar getStationDate() {
        return StationDate;
    }

    public void setStationDate(Calendar stationDate) {
        StationDate = stationDate;
    }

    @JsonProperty("ShiftType")
    public int getShiftType() {
        return ShiftType;
    }

    public void setShiftType(int shiftType) {
        ShiftType = shiftType;
    }

    @JsonProperty("SPlantNum")
    public float getSPlantNum() {
        return SPlantNum;
    }

    public void setSPlantNum(float SPlantNum) {
        this.SPlantNum = SPlantNum;
    }

    @JsonProperty("DPlantNum")
    public float getDPlantNum() {
        return DPlantNum;
    }

    public void setDPlantNum(float DPlantNum) {
        this.DPlantNum = DPlantNum;
    }

    @JsonProperty("PlantNum")
    public float getPlantNum() {
        return PlantNum;
    }

    public void setPlantNum(float plantNum) {
        PlantNum = plantNum;
    }

    @JsonProperty("ActNum")
    public float getActNum() {
        return ActNum;
    }

    public void setActNum(float actNum) {
        ActNum = actNum;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("StatusText")
    public String getStatusText() {
        StatusText = SFCTaskReportStatus.getEnumType(Status).getLabel();
        return StatusText;
    }

    public void setStatusText(String statusText) {
        StatusText = statusText;
    }

    @JsonProperty("ReportMode")
    public int getReportMode() {
        return ReportMode;
    }

    public void setReportMode(int reportMode) {
        ReportMode = reportMode;
    }

    @JsonProperty("ReportModeText")
    public String getReportModeText() {
        ReportModeText = SFCTaskReportMode.getEnumType(ReportMode).getLabel();
        return ReportModeText;
    }

    public void setReportModeText(String reportModeText) {
        ReportModeText = reportModeText;
    }

    @JsonProperty("HandoverList")
    public List<Integer> getHandoverList() {
        return HandoverList;
    }

    public void setHandoverList(List<Integer> handoverList) {
        HandoverList = handoverList;
    }

    @JsonProperty("HandoverNames")
    public String getHandoverNames() {
        return HandoverNames;
    }

    public void setHandoverNames(String handoverNames) {
        HandoverNames = handoverNames;
    }

    @JsonProperty("ConfirmID")
    public int getConfirmID() {
        return ConfirmID;
    }

    public void setConfirmID(int confirmID) {
        ConfirmID = confirmID;
    }

    @JsonProperty("ConfirmName")
    public String getConfirmName() {
        return ConfirmName;
    }

    public void setConfirmName(String confirmName) {
        ConfirmName = confirmName;
    }

    @JsonProperty("ConfirmTime")
    public Calendar getConfirmTime() {
        return ConfirmTime;
    }

    public void setConfirmTime(Calendar confirmTime) {
        ConfirmTime = confirmTime;
    }

    @JsonProperty("BadNum")
    public float getBadNum() {
        return BadNum;
    }

    public void setBadNum(float badNum) {
        BadNum = badNum;
    }

    @JsonProperty("IsRepairPlan")
    public int getIsRepairPlan() {
        return IsRepairPlan;
    }

    public void setIsRepairPlan(int isRepairPlan) {
        IsRepairPlan = isRepairPlan;
    }

    @JsonProperty("ProductRepairID")
    public int getProductRepairID() {
        return ProductRepairID;
    }

    public void setProductRepairID(int productRepairID) {
        ProductRepairID = productRepairID;
    }

    @JsonProperty("ComponentTypeText")
    public String getComponentTypeText() {
        return PDMComponentTypes.getEnumType(ComponentType).getLabel();
    }

    public void setComponentTypeText(String componentTypeText) {
        ComponentTypeText = componentTypeText;
    }
}
